package com.xgsm.fastdfsdemo.Service;

import com.xgsm.fastdfsdemo.Bean.BigData;
import com.xgsm.fastdfsdemo.mapper.BigDataMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @ClaseName: BigDataServiceImpl$
 * @Description:
 * @Author: wuhs
 * @Date: 2023/8/21$ 14:54$
 * @param: $
 * @return: $
 */
@Service
public class BigDataServiceImpl implements BigDataService {
    @Autowired
    private BigDataMapper bigDataMapper;
    @Override
    public int insertData(String message, String type,String ipAddr) {
        if (message == null && "".equals(message)) {
            return 0;
        }
        if (type == null && "".equals(type)) {
            return 0;
        }
        long l = System.currentTimeMillis();
        int i = new Long(l).intValue();
        int typeInt = new Integer(type);
        BigData bigData = new BigData();
        bigData.setDataId(i );
        bigData.setDataMessage(message);
        bigData.setDataType(typeInt);
        bigData.setIpAddr(ipAddr);
        // Date date = new Date();
        // SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd :hh:mm:ss");
        bigData.setDataTime(new Date(System.currentTimeMillis()));
       return bigDataMapper.insert(bigData);
    }
}
